package com.gitee.minimalismstyle.fresh.common.data.jdbc.model

import com.gitee.minimalismstyle.fresh.common.data.commons.annotation.LogicDelete
import com.gitee.minimalismstyle.fresh.common.data.commons.annotation.TenantId
import io.swagger.annotations.ApiModelProperty
import org.springframework.data.annotation.*
import org.springframework.data.relational.core.mapping.Table
import java.time.LocalDateTime
import java.io.Serializable

@Table
abstract class Model<ID>: Serializable {
    @Id
    @ApiModelProperty(value = "主键")
    open var id: ID? = null

    @CreatedBy
    @ApiModelProperty(value = "创建人")
    open var createdBy: Long? = null

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @CreatedDate
    open var createdDate: LocalDateTime? = null

    /**
     * 最后更新人
     */
    @LastModifiedBy
    @ApiModelProperty(value = "最后更新人")
    open var lastModifiedBy: Long? = null

    /**
     * 最后更新时间
     */
    @LastModifiedDate
    @ApiModelProperty(value = "最后更新时间")
    open var lastModifiedDate: LocalDateTime? = null

    @Version
    @ApiModelProperty(value = "版本号")
    open var version: Int? = null

    /**
     * 逻辑删除（0：已删除，1：未删除）
     */
    @ApiModelProperty(value = "逻辑删除（0：已删除，1：未删除）")
    @LogicDelete
    open var delFlag: Int = 1

    /**
     * 租户ID
     */
    @ApiModelProperty(value = "租户ID")
    @TenantId
    open var tenantId: Long? = null
}